/*
package com.atguigu.flink.chapter11;

import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.table.api.DataTypes;
import org.apache.flink.table.api.Table;
import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;
import org.apache.flink.table.descriptors.Csv;
import org.apache.flink.table.descriptors.FileSystem;
import org.apache.flink.table.descriptors.Schema;

import static org.apache.flink.table.api.Expressions.$;

*/
/**
 * @Author lizhenchao@atguigu.cn
 * @Date 2021/9/24 10:10
 *//*

public class Flink03_Table_File {
    public static void main(String[] args) {
        Configuration conf = new Configuration();
        conf.setInteger("rest.port", 20000);
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(conf);
        env.setParallelism(2);
        
        StreamTableEnvironment tenv = StreamTableEnvironment.create(env);
        
        Schema schema = new Schema()
            .field("id", DataTypes.STRING())
            .field("ts", DataTypes.BIGINT())
            .field("vc", DataTypes.INT());
        
        // 创建一个动态表与source进行管理
        tenv
            .connect(new FileSystem().path("input/sensor.txt"))
            .withFormat(new Csv())
            .withSchema(schema)
            .createTemporaryTable("sensor");
        
        Table sensor = tenv.from("sensor");
        
        Table result = sensor.select($("id"), $("vc"));
        
        // 创建一个动态表与sink(文件)进行关联
        tenv
            .connect(new FileSystem().path("input/abc"))
            .withFormat(new Csv())
            .withSchema(new Schema()
                            .field("id", DataTypes.STRING())
                            .field("vc", DataTypes.INT()))
            .createTemporaryTable("s1");
        
        // 先与sink关联的临时表插入数据, 则自动写入到文件中
        result.executeInsert("s1");
        
    }
}
*/
